package cn.teud.quwanstore.controller;

import cn.teud.quwanstore.mapper.UserMapper;
import cn.teud.quwanstore.pojo.dto.UserRegDTO;
import cn.teud.quwanstore.pojo.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired(required = false)
    UserMapper mapper;
    @RequestMapping("/reg")
    public int reg(@RequestBody UserRegDTO user){
        System.out.println("user = " + user);
        UserVO u = mapper.selectByUsername(user.getUsername());
        System.out.println(u);
        if (u!=null){
            return 2;
        }
        mapper.insert(user);
        return 1;
    }
}
